package edu.nctu.csie.jichang.database.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class Configuration implements ApplicationContextAware {

	private static Configuration instance = null;
	private static ApplicationContext context;
	
	public void setApplicationContext(ApplicationContext pApplicationContext) throws BeansException {
		context = pApplicationContext;
	}
	
	public static synchronized Configuration getInstance(){
		if(instance == null){
			if(context == null){
				instance = new Configuration();
			}else{
				instance = context.getBean("configuration",Configuration.class);
			}
		}
		return instance;
	}
	
	/** Alter Reference 是否為註解  */
	private boolean ignoreAlterReference = true;
	/**  忽略刪除 table */
	private boolean ignoreDropTable      = false;
	
	/*
	 * PRIMARY KEY Constraints 
	 * FOREIGN KEY Constraints 
	 * UNIQUE Constraints 
	 * CHECK Constraints 
	 * DEFAULT Definitions 
	 * Allowing Null Values 
	 */
	/** 處理 PRIMARY KEY　*/
	private boolean checkPrimaryKey     = true;
	/** 處理 INDEX */
	private boolean checkIndex          = true;
	/** 處理 FOREIGN KEY */
	private boolean checkForeignKey     = true;
	/** 處理 UNIQUE */
	private boolean checkUnique         = true;
	/** 處理 Default 欄位 */
	private boolean checkDeafult        = true;
	/** 處理 allowing value */
	private boolean checkAllowingValue  = false;
	/** 處理 Constraint　Name　相異 */
	private boolean checkConstraintName = true;
	
	public boolean isCheckPrimaryKey() {
		return checkPrimaryKey;
	}
	public void setCheckPrimaryKey(boolean checkPrimaryKey) {
		this.checkPrimaryKey = checkPrimaryKey;
	}
	public boolean isCheckUnique() {
		return checkUnique;
	}
	public void setCheckUnique(boolean checkUnique) {
		this.checkUnique = checkUnique;
	}
	public boolean isCheckConstraintName() {
		return checkConstraintName;
	}
	public void setCheckConstraintName(boolean checkConstraintName) {
		this.checkConstraintName = checkConstraintName;
	}
	public boolean isCheckDeafult() {
		return checkDeafult;
	}
	public void setCheckDeafult(boolean checkDeafult) {
		this.checkDeafult = checkDeafult;
	}
	public boolean isCheckAllowingValue() {
		return checkAllowingValue;
	}
	public void setCheckAllowingValue(boolean checkAllowingValue) {
		this.checkAllowingValue = checkAllowingValue;
	}
	public boolean isCheckForeignKey() {
		return checkForeignKey;
	}
	public void setCheckForeignKey(boolean checkForeignKey) {
		this.checkForeignKey = checkForeignKey;
	}
	public boolean isIgnoreAlterReference() {
		return ignoreAlterReference;
	}
	public void setIgnoreAlterReference(boolean ignoreAlterReference) {
		this.ignoreAlterReference = ignoreAlterReference;
	}
	public boolean isCheckIndex() {
		return checkIndex;
	}
	public void setCheckIndex(boolean checkIndex) {
		this.checkIndex = checkIndex;
	}

	public boolean isIgnoreDropTable() {
		return ignoreDropTable;
	}

	public void setIgnoreDropTable(boolean ignoreDropTable) {
		this.ignoreDropTable = ignoreDropTable;
	}

}